this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.Ui=this.BX.Landing.Ui||{};this.BX.Landing.Ui.Panel=this.BX.Landing.Ui.Panel||{};this.BX.Landing.Ui.Panel.Formsettingspanel=this.BX.Landing.Ui.Panel.Formsettingspanel||{};(function(e,t,n,s,i,r,a,o,c,l){"use strict";function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function g(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var h=function(e){babelHelpers.inherits(t,e);function t(e){var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));n.setEventNamespace("BX.Landing.UI.Panel.FormSettingsPanel.Content.SpamProtection.KeysForm");a.Dom.addClass(n.layout,"landing-ui-form-form-keys-settings");n.getButton().renderTo(n.layout);n.value={};return n}babelHelpers.createClass(t,[{key:"getButton",value:function e(){var t=this;return this.cache.remember("button",(function(){return new o.Button({text:t.options.buttonLabel,color:o.ButtonColor.LIGHT_BORDER,onclick:function e(){t.getButton().setWaiting(true);a.Runtime.loadExtension("crm.form.captcha").then((function(e){var n=e.Captcha;t.getButton().setWaiting(false);return n.open()})).then((function(e){t.value=g({},e);var n=c.FormSettingsPanel.getInstance();n.getFormDictionary().captcha.hasKeys=a.Type.isStringFilled(e.key)&&a.Type.isStringFilled(e.secret);var s=n.getSidebarButtons().find((function(e){return e.isActive()}));if(s){s.getLayout().click()}t.emit("onChange")}))}})}))}},{key:"serialize",value:function e(){return this.value}}]);return t}(r.FormSettingsForm);function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var d=function(e){babelHelpers.inherits(i,e);function i(e){var o;babelHelpers.classCallCheck(this,i);o=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).call(this,e));o.setEventNamespace("BX.Landing.UI.Panel.FormSettingsPanel.SpamProtection");var c=new t.HeaderCard({title:n.Loc.getMessage("LANDING_SPAM_PROTECTION_TITLE")});var u=new l.MessageCard({header:n.Loc.getMessage("LANDING_FORM_EDITOR_FORM_CAPTCHA_MESSAGE_TITLE"),description:n.Loc.getMessage("LANDING_FORM_EDITOR_FORM_CAPTCHA_MESSAGE_TEXT"),angle:false});var g=new r.FormSettingsForm({id:"type",description:null,fields:[new l.MessageCard({selector:"warning-captcha",context:"warning",description:n.Loc.getMessage("LANDING_SPAM_PROTECTION_MESSAGE_WARNING_RECAPTCHA").replace("#URL_POLICIES_PRIVACY#","https://policies.google.com/privacy").replace("#URL_POLICIES_TERMS#","https://policies.google.com/terms"),angle:false,closeable:false}),new s.RadioButtonField({selector:"use",title:n.Loc.getMessage("LANDING_SPAM_PROTECTION_TABS_TITLE"),value:a.Text.toBoolean(o.options.formOptions.data.recaptcha.use)?"hidden":"disabled",items:[{id:"disabled",title:n.Loc.getMessage("LANDING_SPAM_PROTECTION_TAB_DISABLED"),icon:"landing-ui-spam-protection-icon-disabled"},{id:"hidden",title:n.Loc.getMessage("LANDING_SPAM_PROTECTION_TAB_HIDDEN"),icon:"landing-ui-spam-protection-icon-hidden"}]})]});o.addItem(c);o.addItem(u);o.addItem(g);g.subscribe("onChange",o.onTypeChange.bind(babelHelpers.assertThisInitialized(o)));o.onTypeChange();return o}babelHelpers.createClass(i,[{key:"hasDefaultsCaptchaKeys",value:function e(){return a.Text.toBoolean(this.options.formOptions.captcha.hasDefaults)}},{key:"hasCustomKeys",value:function e(){return a.Text.toBoolean(this.options.dictionary.captcha.hasKeys)}},{key:"onTypeChange",value:function e(){a.Dom.remove(this.getCustomKeysForm().getLayout());a.Dom.remove(this.getRequiredKeysForm().getLayout());a.Dom.remove(this.getKeysSettingsForm().getLayout());if(this.getValue().recaptcha.use){if(!this.hasDefaultsCaptchaKeys()&&!this.hasCustomKeys()){this.addItem(this.getRequiredKeysForm())}if(!this.hasDefaultsCaptchaKeys()&&this.hasCustomKeys()||this.hasDefaultsCaptchaKeys()&&this.hasCustomKeys()){this.addItem(this.getKeysSettingsForm())}if(this.hasDefaultsCaptchaKeys()&&!this.hasCustomKeys()){this.addItem(this.getCustomKeysForm())}}}},{key:"getCustomKeysForm",value:function e(){return this.cache.remember("customKeysForm",(function(){return new h({title:n.Loc.getMessage("LANDING_FORM_EDITOR_FORM_CAPTCHA_KEYS_FORM_TITLE"),buttonLabel:n.Loc.getMessage("LANDING_FORM_EDITOR_FORM_CAPTCHA_KEYS_FORM_CUSTOM_BUTTON_LABEL")})}))}},{key:"getRequiredKeysForm",value:function e(){return this.cache.remember("requiredKeysForm",(function(){return new h({title:n.Loc.getMessage("LANDING_FORM_EDITOR_FORM_CAPTCHA_KEYS_FORM_TITLE"),buttonLabel:n.Loc.getMessage("LANDING_FORM_EDITOR_FORM_CAPTCHA_KEYS_FORM_BUTTON_LABEL"),description:n.Loc.getMessage("LANDING_FORM_EDITOR_FORM_CAPTCHA_KEYS_FORM_REQUIRED_DESCRIPTION")})}))}},{key:"getKeysSettingsForm",value:function e(){return this.cache.remember("keysSettingsForm",(function(){return new h({title:n.Loc.getMessage("LANDING_FORM_EDITOR_FORM_CAPTCHA_KEYS_FORM_TITLE"),buttonLabel:n.Loc.getMessage("LANDING_FORM_EDITOR_FORM_CAPTCHA_KEYS_FORM_CHANGE_BUTTON_LABEL")})}))}},{key:"valueReducer",value:function e(t){return{recaptcha:_(_(_({use:t.use==="hidden"},this.getKeysSettingsForm().serialize()),this.getCustomKeysForm().serialize()),this.getRequiredKeysForm().serialize())}}},{key:"onChange",value:function e(t){this.emit("onChange",_(_({},t.getData()),{},{skipPrepare:true}))}}]);return i}(i.ContentWrapper);e.default=d})(this.BX.Landing.Ui.Panel.Formsettingspanel.Content=this.BX.Landing.Ui.Panel.Formsettingspanel.Content||{},BX.Landing.UI.Card,BX.Landing,BX.Landing.UI.Field,BX.Landing.UI.Panel,BX.Landing.UI.Form,BX,BX.UI,BX.Landing.UI.Panel,BX.Landing.UI.Card);
//# sourceMappingURL=spam-protection.bundle.map.js